package com.gz.golfgame.ui;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.gz.golfgame.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ReadyActivity extends Activity {

    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.defen)
    TextView defen;
    @BindView(R.id.glod)
    TextView glod;
    @BindView(R.id.flagblackdong3)
    ImageView flagblackdong3;
    @BindView(R.id.flag3)
    ImageView flag3;
    @BindView(R.id.dong3)
    ImageView dong3;
    @BindView(R.id.relativeLayout3)
    RelativeLayout relativeLayout3;
    @BindView(R.id.flagblackdong2)
    ImageView flagblackdong2;
    @BindView(R.id.flag2)
    ImageView flag2;
    @BindView(R.id.dong2)
    ImageView dong2;
    @BindView(R.id.relativeLayout2)
    RelativeLayout relativeLayout2;
    @BindView(R.id.flagblackdong1)
    ImageView flagblackdong1;
    @BindView(R.id.flag1)
    ImageView flag1;
    @BindView(R.id.dong1)
    ImageView dong1;
    @BindView(R.id.relativeLayout1)
    RelativeLayout relativeLayout1;
    @BindView(R.id.flagblackdong7)
    ImageView flagblackdong7;
    @BindView(R.id.flag7)
    ImageView flag7;
    @BindView(R.id.dong7)
    ImageView dong7;
    @BindView(R.id.relativeLayout7)
    RelativeLayout relativeLayout7;
    @BindView(R.id.flagblackdong8)
    ImageView flagblackdong8;
    @BindView(R.id.flag8)
    ImageView flag8;
    @BindView(R.id.dong8)
    ImageView dong8;
    @BindView(R.id.relativeLayout8)
    RelativeLayout relativeLayout8;
    @BindView(R.id.flagblackdong9)
    ImageView flagblackdong9;
    @BindView(R.id.flag9)
    ImageView flag9;
    @BindView(R.id.dong9)
    ImageView dong9;
    @BindView(R.id.relativeLayout9)
    RelativeLayout relativeLayout9;
    @BindView(R.id.flagblackdong11)
    ImageView flagblackdong11;
    @BindView(R.id.flag11)
    ImageView flag11;
    @BindView(R.id.dong11)
    ImageView dong11;
    @BindView(R.id.relativeLayout11)
    RelativeLayout relativeLayout11;
    @BindView(R.id.flagblackdong12)
    ImageView flagblackdong12;
    @BindView(R.id.flag12)
    ImageView flag12;
    @BindView(R.id.dong12)
    ImageView dong12;
    @BindView(R.id.relativeLayout12)
    RelativeLayout relativeLayout12;
    @BindView(R.id.flagblackdong6)
    ImageView flagblackdong6;
    @BindView(R.id.flag6)
    ImageView flag6;
    @BindView(R.id.dong6)
    ImageView dong6;
    @BindView(R.id.relativeLayout6)
    RelativeLayout relativeLayout6;
    @BindView(R.id.flagblackdong10)
    ImageView flagblackdong10;
    @BindView(R.id.flag10)
    ImageView flag10;
    @BindView(R.id.dong10)
    ImageView dong10;
    @BindView(R.id.relativeLayout10)
    RelativeLayout relativeLayout10;
    @BindView(R.id.flagblackdong4)
    ImageView flagblackdong4;
    @BindView(R.id.flag4)
    ImageView flag4;
    @BindView(R.id.dong4)
    ImageView dong4;
    @BindView(R.id.relativeLayout4)
    RelativeLayout relativeLayout4;
    @BindView(R.id.flagblackdong5)
    ImageView flagblackdong5;
    @BindView(R.id.flag5)
    ImageView flag5;
    @BindView(R.id.dong5)
    ImageView dong5;
    @BindView(R.id.relativeLayout5)
    RelativeLayout relativeLayout5;

    private int time1 = 0;
    private Handler handler=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ready);
        ButterKnife.bind(this);

        //Glide.with(this).load(R.drawable.ready).into(imgview);

        visiblelight(flag1);
        visibleflag(flag6);
    }

    @OnClick(R.id.glod)
    public void onClick() {
    }

    /* @OnClick(R.id.btn_next)
     public void onClick(View view) {
         switch (view.getId()){
             case R.id.btn_next:
                 Intent intent = new Intent(MainActivity.this,ReadyActivity.class);
                 startActivity(intent);
                 break;
         }
     }*/


    public class MyRunnable implements Runnable{

        @Override
        public void run() {
            // TODO Auto-generated method stub
            while (time1 > 0) {
                time1--;
                try {
                    Thread.sleep(1000);
                    int hh = time1 / 60 / 60 % 60;
                    int mm = time1 / 60 % 60;
                    int ss = time1 % 60;
                    time.setText(hh + ":" + mm + ":" + ss);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }}


    private  void gonelight(View view){
        view.setVisibility(View.GONE);
    }
    private  void goneflag(View view){
        view.setVisibility(View.GONE);
    }
    private  void visiblelight(View view){
        view.setVisibility(View.VISIBLE);
        Glide.with(this).load(R.drawable.dong).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into((ImageView) view);
    }
    private  void visibleflag(View view){
        view.setVisibility(View.VISIBLE);
        Glide.with(this).load(R.drawable.flag).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into((ImageView) view);
    }

}
